package com.har01d.tool;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@SpringBootApplication
@RequestMapping(value = "/", produces = "text/xml; charset=UTF-8")
public class Application {

    private static final Logger log = LoggerFactory.getLogger(Application.class);

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }

    @RequestMapping("rpc/obtainTicket.action")
    public Object obtainTicket(String salt, String userName) {
        log.info("obtaining ticket for user: " + userName);
        return JetBrainsUtil.obtainTicket(salt, userName);
    }

    @RequestMapping("rpc/releaseTicket.action")
    public Object releaseTicket(String salt) {
        return JetBrainsUtil.releaseTicket(salt);
    }

    @RequestMapping("rpc/prolongTicket.action")
    public Object prolongTicket(String salt) {
        return JetBrainsUtil.prolongTicket(salt);
    }

    @RequestMapping("rpc/ping.action")
    public Object ping(String salt) {
        return JetBrainsUtil.ping(salt);
    }

}
